Skip to content

Speedup CI #1852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 30, 2023
Merged

Speedup CI #1852

merged 24 commits into from
Aug 30, 2023

Conversation

AntoniosBarotsis
Copy link
Contributor

@AntoniosBarotsis AntoniosBarotsis commented Aug 28, 2023

This Pull Request closes #1844.

Changes

Fix Warnings

These changes resolved all the warnings.

Caching

Used rust-cache as mentioned in the issue.

Note
rust-cache:

  • caches .cargo/ and target/
  • hashes Cargo.lock for the key automatically

hence their removal from the ci script

I kept the cache-name around and added a target variable as well.

Is it any better?

I think the best way to figure that out would be to wait for another commit to be made to master which I can merge to my fork so we can compare the CI times between that and the original.

I forked at b36ffc9 and here's some numbers

In my experience, +- 2 minutes can often just be random noise when it comes to GA

I would guess that the warm cache time is more representative of the change since, well, the original repository should also have a warm cache. But again, a more serious comparison would be to wait for the next commit.

And also not having a wall of warnings makes it easier to spot any that are actually relevant when they appear 😅

Other

I also mention this in the yml itself but for some reason there seems to be some issue with the x86_64-unknown-linux-musl target and the dtolnay/rust-toolchain action.

Even though the rustup target should be installed, the subsequent build fails. I instead install it manually which works fine (it is also cached so subsequent runs don't suffer).

Let me know if you have any questions or want any changes made!

Also the last CI run after I changed a comment decided to fail due to a timeout, I'm guessing because I've been running it quite a few times in the last few hours. Anyway, seems unrelated + i ran the failed task again and it worked fine

@extrawurst
Copy link
Collaborator

can you make sure cd.yml is kept in sync?

@AntoniosBarotsis
Copy link
Contributor Author

I can take a look at that sometime today/tomorrow as well

@AntoniosBarotsis
Copy link
Contributor Author

I merged f639f4a and c38b1d1 into my fork and here's some more numbers:

The fork's master branch was included as a sanity check to make sure that it has roughly the same times as the original repo (which it should as I have not modified it). Somehow it ended up being a bit slower, go figure.

The original repo shows 2 times as each commit was pushed separately unlike my fork where both were pushed together.

The great news is that this also improves the build task times!

Overall, this seems to be quite a bit faster, at least in these 2 commits that I tested it on.

I won't be able to really test the CD workflow but I'll make the same changes there nontheless.

@extrawurst
Copy link
Collaborator

would like to put this into action in 0.24.1 patch release tomorrow. will wait for the changes in cd.yml

@AntoniosBarotsis
Copy link
Contributor Author

I'll definitely try to have it ready by then so I can see it tested as well.

@AntoniosBarotsis
Copy link
Contributor Author

AntoniosBarotsis commented Aug 29, 2023

I checked the actions used in the CD workflow and made sure they are either on their latest version + switched the toolchain one as I did in the CI workflow earlier.

I also opted to use ${{ matrix.os }}-${{ env.cache-name }}-${{ matrix.rust }} as the cache key everywhere instead of prefixing build-linux-musl and build-linux-arm with the target. This should not change the CI times, I'll run a test on an empty commit to make sure that that is the case.

Lastly, by getting CD to use the same cache key format, it should benefit from the fresh cache that CI created in the last commit.

@AntoniosBarotsis
Copy link
Contributor Author

I changed from the key attribute to shared-key to achieve this. Manually inspecting the generated keys (which you can view in the logs of each action > Restore Cargo Cache > Cache Configuration > Cache Key) reveals that for example build-linux-arm (stable) and build (ubuntu-latest, stable) have the same cache key which was not the case before. This should also guarantee that the CD workflow will use the existing cache generated by CI.

I'm gonna wait for the cache to warm up and run the workflow once more on an empty commit to make sure nothing changed in the times. After that, I think everything is done from my side so far, let me know!

@AntoniosBarotsis
Copy link
Contributor Author

This actually seems to worsen performance as sometimes the cache is not properly saved since multiple jobs are trying to access it at the same time

Failed to save: Unable to reserve cache with key v0-rust-ubuntu-latest-ci-1.65-e8f5d070-722cda0f, 
another job may be creating this cache. More details: Cache already exists.

To get around this, I will only keep the shared keys for one of the CI jobs (which is really all that was needed, in retrospect). Taking a look at the latest CD run it seems that most of the time is actually spent building for windows and not arm which I would initially expect. This means that sharing the cache from the build job should be pretty effective in reducing CD times.

@AntoniosBarotsis
Copy link
Contributor Author

AntoniosBarotsis commented Aug 29, 2023

This last change has made CI run in ~10 minutes again like last time so it seems to be working fine again.

This should also benefit CD heavily, to make sure that the cache is being utilized correctly when we do run CD we should check that the key for build (windows-latest, stable) for example is the same as release (windows-latest).

One small issue with this is that CI currently does not run on ubuntu-22.04, just ubuntu-latest which, while they are technically the same I belive, will result in different cache keys and thus the CD task won't have a cache to utilize from the previous CI run. Each CD run however will update the cache meaning that the next run will have one, just not as up to date as the other OSes.

@AntoniosBarotsis
Copy link
Contributor Author

AntoniosBarotsis commented Aug 29, 2023

Finally, I also added caching in the udeps and linting jobs since rust-cache also caches the binaries found in ~/.cargo.

In the best case scenario, CI can take as little as 8m 19s which is over an hour of total runtime less than the existing workflow
(1h 21m 39s vs 2h 32m 54s)

Initially, I wasn't planning on adding this but it seems that with no code changes they actually take more time than all other steps.

Sorry for the influx of comments, I hadn't done some of this stuff before 😅
If something is unclear, let me know!

@extrawurst extrawurst merged commit ea9314e into gitui-org:master Aug 30, 2023
@extrawurst
Copy link
Collaborator

Thank you!

IndianBoy42 pushed a commit to IndianBoy42/gitui that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Room for potential CI speedups
2 participants